package com.itbaizhan;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class PropertiesTest02 {
    public static void main(String[] args) throws IOException {
        //实例化properties对象
        Properties properties = new Properties();
        //获取读取properties 文件的输入流对象
        //当前类的加载器（PropertiesTest.class.getClassLoader()），
        //getResourceAsStream()这方法返回InputStream
         InputStream is = PropertiesTest02.class.getClassLoader().getResourceAsStream("test.properties");
        //通过load()读取properties文件并解析
        properties.load(is);
        ////获取properties文件中的内容 ,getProperty()
        String value1 = properties.getProperty("key1");
        String value2 = properties.getProperty("key2");
        String value3 = properties.getProperty("key3");
        System.out.println(value1+"\t"+value2+"\t"+value3);
    }
}
